<?php

namespace Home\Controller;

use Think\Controller;

class HomeController extends Controller {

    public function index() {
        obtain();
        $this->display('index');
    }

    public function left() {
        $this->display('left');
    }

    public function top() {
        $this->display('top');
    }

    public function right() {
        $result = M('setting')->select();
        $this->assign('list', $result);
        $this->display('right');
    }

    public function updateSet() {
        if (empty($_POST)) {
            $this->error('错误的访问！');
        }
        $setting = M('setting');
        $data = $setting->create();
        if ($data) {
            $map['key'] = $data['key'];
            if ($setting->where($map)->save()) {
                $this->success('成功修改！');
            } else {
                $this->error('未修改！');
            }
        } else {
            $this->error('错误访问！');
        }
    }

    /**
     * 退出 
     */
    public function dropOut() {
        session(null);
        $this->redirect('Home/Index/Index');
    }

}
